
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html"; charset="utf-8" />
    <title></title>
    <link href="js/bstable/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <link href="js/bstable/css/bootstrap-table.css" rel="stylesheet" type="text/css">
    <link href="css/table.css" rel="stylesheet" type="text/css">

    <script src="/js/vue.js"></script>
    <script src="/js/axios.min.js"></script>
</head>
<body style="background-color: #ecf0f5;font-family: 微软雅黑;color: #475059;min-width: 1000px;overflow: auto">
<div id="app">
<div class="notice_main">
    <div class="notice_check">
        <div class="l_left">
            <input type="text" v-model="adminName" name="adminName" class="form-control" placeholder="请输入姓名">


        </div>
        <button type="button" @click="queryApp()" class="btn btn-primary">查询</button>

        <div class="notice_nav r_right">
            <a href="/admin_add.html" class="btn btn-default" >新增管理员</a>
        </div>

    <table class="table table-bordered  table-hover">
        <tr>
            <th type="radio">选择</th>
            <th>编号</th>
            <th>管理员姓名</th>
            <th>管理员注册日期</th>
            <th>创建日期</th>
            <th>操作</th>
        </tr>
        <tr v-for="(item,index) in adminList">
            <td><label>
                <input type="checkbox"   id="inlinecheckbox1" value="true">
            </label></td>
            <td> {{index+1}} </td>
            <td>{{item.admin_name}}</td>
            <td>{{item.admin_date}}</td>
            <td>{{item.create_date}}</td>
            <td> <a   @click="updateAdmin(item.admin_id)">修改</a> |  <a   @click="delAdmin(item.admin_id)">删除</a></td>
        </tr>
    </table>
    </div>
</div>
</body>

</html>
<script>
    new Vue({
        el:"#app",
        data:{
            adminName:'',
            adminList:[]
        },
        methods:{
            queryApp:function (){
                _this = this
                //查询管理员信息
                axios.get('/admin/list1',{
                    params: {
                        adminName:this.adminName
                    }
                }).then(function (response) {
                    _this.adminList=response.data;
                    console.log(response.data);
                })
                    .catch(function (error) {
                        console.log(error);
                    });
            },
            delAdmin:function (admin_id){
                alert(admin_id)
                window.localStorage.setItem("admin_id", admin_id);
                location.href="admin.html"
                axios.get('/admin/del/?admin_id='+admin_id)
                .then(function (response) {
                console.log(response.date);
                if (response.date==1){
                    alert("删除成功！")
                    location.href="admin.html"
                }
            })
        .catch(function (error) {
            console.log(error);
        });
            },
            updateAdmin: function (admin_id) {
                alert(admin_id)
                window.localStorage.setItem("sid", admin_id);
                location.href = "admin_update.html"
            },
        },
        mounted() {
            _this = this
            axios.get('/admin/list1',{
                params: {
                    adminName: this.adminName

                }
            }).then(function (response){
                _this.adminList=response.data;
                console.log(response.data);
            })
                .catch(function (error){
                    console.log(error);
                });
        }
    })
</script>